/**
 * 关键点
 * - async异步函数中使用await后，await后面的代码将被当做await后面接的Promise的then中的代码
 * @returns {Promise<void>}
 */
async function async1() {
  console.log('async1 start')
  await async2() // Promise.resolve()
  //console.log('async1 end')将被当做async2()的promise的then中的代码
  //Promise.resolve().then(() => {console.log('async1 end')})
  console.log('async1 end')
}

async function async2() {
  console.log('async2')
}

console.log('script start')

setTimeout(() => {
  console.log('setTimeout')
}, 0)

async1()

new Promise((resolve) => {
  console.log('promise1')
  resolve()
}).then(() => {
  console.log('promise2')
})

console.log('script end')

//script start
// async1 start
// async2
// promise1
// script end
// async1 end
// promise2
// setTimeout
